32 Lecture
CS402
Midterm & Final Term Short Notes
Trees
In computer science, trees are a widely used data structure that can be used to represent hierarchical relationships between elements. Each node in a tree contains a value, and can have zero or more child nodes. Trees can be used to model file s
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is the maximum number of nodes at level 4 in a binary tree? a) 8 b) 16 c) 32 d) 64 Answer: b) 16 Which of the following is not a binary tree traversal algorithm? a) Preorder b) Inorder c) Postorder d) Depth-first search Answer: d) Depth-first search Which of the following statements is true about a binary search tree? a) The left subtree of a node contains only nodes with keys greater than the node's key b) The right subtree of a node contains only nodes with keys less than the node's key c) The left and right subtrees of a node contain nodes with keys greater than and less than the node's key, respectively d) None of the above Answer: c) The left and right subtrees of a node contain nodes with keys greater than and less than the node's key, respectively A binary tree is said to be complete if: a) Every node has at most one child b) Every node has at least one child c) All levels of the tree are completely filled d) None of the above Answer: c) All levels of the tree are completely filled Which of the following is a self-balancing binary search tree? a) AVL tree b) B-tree c) Red-black tree d) All of the above Answer: d) All of the above Which of the following is not a common tree traversal algorithm? a) Breadth-first search b) Depth-first search c) Preorder traversal d) Level-order traversal Answer: d) Level-order traversal A full binary tree is a tree in which: a) Every node has at most one child b) Every node has at least one child c) All internal nodes have two children and all leaves have the same depth or level d) None of the above Answer: c) All internal nodes have two children and all leaves have the same depth or level The height of a binary tree is defined as: a) The number of nodes in the tree b) The maximum number of nodes at any level in the tree c) The maximum distance from the root node to any leaf node in the tree d) None of the above Answer: c) The maximum distance from the root node to any leaf node in the tree Which of the following is not a type of binary tree? a) Full binary tree b) Complete binary tree c) Perfect binary tree d) Balanced binary tree Answer: d) Balanced binary tree Which of the following is not a tree traversal algorithm? a) Depth-first search b) Breadth-first search c) Preorder traversal d) Postorder search Answer: d) Postorder search
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is a tree in computer science? A tree is a non-linear data structure used to represent hierarchical relationships between elements. It consists of a collection of nodes connected by edges. What is a binary tree? A binary tree is a tree data structure where each node can have at most two children, referred to as the left child and the right child. What is a complete binary tree? A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible. What is a balanced binary tree? A balanced binary tree is a binary tree in which the left and right subtrees of every node differ in height by no more than one. What is a traversal of a tree? A traversal of a tree is a process of visiting each node in the tree exactly once in some order. What is the preorder traversal of a binary tree? The preorder traversal of a binary tree visits each node in the following order: root, left subtree, right subtree. What is the inorder traversal of a binary tree? The inorder traversal of a binary tree visits each node in the following order: left subtree, root, right subtree. What is the postorder traversal of a binary tree? The postorder traversal of a binary tree visits each node in the following order: left subtree, right subtree, root. What is a binary search tree? A binary search tree is a binary tree in which every node's left subtree contains only nodes with keys less than the node's key, and every node's right subtree contains only nodes with keys greater than the node's key. What is a heap? A heap is a complete binary tree that satisfies the heap property: the key of each node is either greater than or equal to (in a max heap) or less than or equal to (in a min heap) the keys of its children.